package com.iceframework.core.quartz.job;

import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.iceframework.core.utils.HttpClientUtils;

/**
 * SchedulerJob 任务执行实现
 * 
 * @author Palo
 *
 */
public class HttpClientQuartzJob implements Job {

	private Logger logger = LoggerFactory.getLogger(this.getClass());

	@Override
	public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
		// 这里可以获取控制器绑定的值，实际应用中可以设置为某个活动的id,以便进行数据库操作
		JobDetail jobDetail = jobExecutionContext.getJobDetail();
		JobDataMap jobDataMap = jobDetail.getJobDataMap();
		String url = String.valueOf(jobDataMap.get("url"));
		Object jobName = jobDetail.getKey();
		String result = HttpClientUtils.doGet(url);
		logger.info("定时任务[{}]返回结果[{}]", jobName, result);
	}

}
